#{extends '/template/main.html' /}
<div class="panel panel-default">
    <div class="panel-heading">
        <h3 class="panel-title">创建餐饮订单</h3>
    </div>
    <div class="panel-body">

        <form method="POST" role="form" action="/BS0017/admin/order/createForSeat" class="form-horizontal validate">
            <input id="seatId" name="id" type="hidden" value="${seat?.id}">
            <div class="form-group">
                <label class="col-sm-2 control-label" for="field-1">桌位编号</label>

                <div class="col-sm-10">
                    <input type="text" name="seat.seatNo" class="form-control" placeholder="" readonly value="${seat?.seatNo}">
                </div>
            </div>

            <div class="form-group-separator"></div>
            <div class="form-group">
                <label class="col-sm-2 control-label" for="field-1">金额</label>

                <div class="col-sm-10">
                    <input id="idAmount" type="text" name="amount"  class="form-control" data-validate="required" placeholder="请输入金额" value="">
                </div>
            </div>

            <div class="form-group-separator"></div>

            <div class="form-group">
                <label class="col-sm-2 control-label" for="field-5"></label>

                <div class="col-sm-10">
                    <button type="button" onclick="saveOrder()" class="btn btn-success">&nbsp;&nbsp;确定生成订单&nbsp;&nbsp;</button>
                    <button type="reset" class="btn btn-white">&nbsp;&nbsp;重置&nbsp;&nbsp;</button>
                </div>

            </div>

        </form>

    </div>
</div>

<!-- Imported styles on this page -->
<link rel="stylesheet" href="/public/js/wysihtml5/src/bootstrap-wysihtml5.css">
<link rel="stylesheet" href="/public/js/uikit/vendor/codemirror/codemirror.css">
<link rel="stylesheet" href="/public/js/uikit/uikit.css">
<link rel="stylesheet" href="/public/js/uikit/css/addons/uikit.almost-flat.addons.min.css">
<script src="/public/js/wysihtml5/lib/js/wysihtml5-0.3.0.js"></script>
<!-- Imported scripts on this page -->
<script src="/public/js/wysihtml5/src/bootstrap-wysihtml5.js"></script>
<script src="/public/js/uikit/vendor/codemirror/codemirror.js"></script>
<script src="/public/js/uikit/vendor/marked.js"></script>
<script src="/public/js/uikit/js/uikit.min.js"></script>
<script src="/public/js/uikit/js/addons/htmleditor.min.js"></script>
<script src="/public/js/ckeditor/ckeditor.js"></script>
<script src="/public/js/ckeditor/adapters/jquery.js"></script>

<!-- Imported scripts on this page -->
<script src="/public/js/jquery-validate/jquery.validate.min.js"></script>
<script>

    var pageNumber  = '${pageNumber}';
    $(function () {

    })

    function saveOrder() {
        var id = $('#seatId').val();
        var amount = $('#idAmount').val();
        if(id == null || id == '' || id < 0){
            layer.msg('餐位为空,无法生成账单!');
            return ;
        }

        if(isNaN(amount) || amount <= 0){
            layer.msg('请填写正确金额!');
            return ;
        }

        $.getJSON('/BS0017/admin/order/createForSeat',{id:id,amount:amount},function (data) {
            console.log(data);
            if(data.success){
                layer.msg('订单创建成功!');
                window.location.href="/BS0023/admin/order/detail/"+data.orderId+'/'+pageNumber;
            }else {
                layer.msg(data.msg);
                return ;
            }
        })

    }

</script>